<?php
/**
 * 容器
 */

class Container
{
    protected $container = array();

    protected static $instance;

    private function __construct(){}

    public static function instance()
    {
        self::$instance || self::$instance = new self();
        return self::$instance;
    }

    public function __clone()
    {
        self::$instance || self::$instance = new self();
        return self::$instance;
    }

    public function __set($key, $value)
    {
        (isset($this->{$key})) ? ($this->{$key} = $value) : ($this->container[$key] = $value);
    }

    public function __get($key)
    {
        return (isset($this->$key)) ? $this->$key : (isset($this->container[$key]) ? $this->container[$key] : NULL);
    }
}
?>